package com.lz.ui_lib;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;

import com.lz.ui_lib.bean.ActivityInfos;
import com.lz.ui_lib.component.BlurComponent;

/**
 * UI库测试说明类
 * <p>
 * Created by liuyakui on 2022/2/13.
 */
public class UiTestActivity extends FragmentActivity {
    private ActivityInfos mActivityInfos;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ui_activity_test);
        mActivityInfos = (ActivityInfos) getIntent().getSerializableExtra("extra");
        LinearLayout ll = findViewById(R.id.ui_activity_contain);
        getWidget(ll);
    }

    private void getWidget(LinearLayout ll) {
        switch (mActivityInfos.getHost()) {
            case "gifplay":
                inflate(R.layout.ui_gif, ll);
                break;

            case "radaranim":
                inflate(R.layout.ui_radar, ll);
                break;

            case "blur":
                ll.addView(new BlurComponent(this));
                break;

            case "palette":
                inflate(R.layout.ui_palette, ll);
                break;

            case "flow":
                inflate(R.layout.ui_flow, ll);
                break;
        }
    }

    private void inflate(int resId, LinearLayout ll) {
        LayoutInflater.from(this).inflate(resId, ll, true);
    }
}